<template>
  <up-swiper
    height="290rpx"
    radius="20rpx"
    :list="banners"
    keyName="image" />
</template>

<script lang="ts" setup>
  import { onMounted, ref } from 'vue'
  import type { Banner } from '@/types/api.d.ts'

  const banners = ref<string[]>([])

  onMounted(() => {
    getBanner()
  })

  const getBanner = async () => {
    const params = { type: 2 }

    const res = await uni.$u.get<Banner[]>('/banner/index', params)

    if (res.code === 1) {
      banners.value = res.data.map((each) => each.image)
    }
  }
</script>

<style lang="scss" scoped></style>
